﻿using System;

namespace Array
{
    class Program
    {
        static void Main(string[] args)
        {
           
            

            int[] myArray = { 2, 3, 5, 7 };
            int max, min,  sum;
            double aver;
            new Program().Calculate(myArray, out max, out min, out aver, out sum);
            Console.WriteLine($"数组的最大值为:{max}");
            Console.WriteLine($"数组的最小值为:{min}");
            Console.WriteLine($"数组的平均值为:{aver}");
            Console.WriteLine($"数组的和为:{sum}");
             

        }
       
        public void Calculate(int[] a, out int max, out int min, out double aver, out int sum)
        {
            max = a[0];
            min = a[0];
            sum = a[0];
            aver = a[0];
            for (int i = 0; i < a.Length; i++)
            {
                if (a[i] > max)
                    max = a[i];
                else if (a[i] < min)
                    min = a[i];
                sum += a[i];
            }
            aver = (double)sum / a.Length;

        }
    }
}
